/******************************************************************************
* This file is part of is32p218 platform,
* Copyright (c) 2009 HangZhou InfoStrong CO.,LTD. All rights reserved.
* This software may only be used under the terms of a valid, current,
* end user license from InfoStrong.
* Nothing else gives you the right to use this software.   
*
* Name:   os_mem.h
* Desc:   isOS memory management header file
* Author: Jerry
* Date:   2009-11-23
* Note:   
* History:
*
******************************************************************************/
#include "isOS.h"
#include "os_cfg.h"

#ifndef __OS_MEM_H__
#define __OS_MEM_H__

#if (OS_MEM_EN ==1 )

#ifdef __cplusplus
extern "C" {
#endif

/*-----------------------------------------------------------
 * MACROS AND DEFINITIONS
 *----------------------------------------------------------*/


typedef struct _isOS_MEM
{
   LIST_QUE wait_queue;

   void * start_addr;       //-- Memory pool actual start address
   void * free_list;        //-- Ptr to free block list

   isOS_U32 block_size; 	//-- Actual block size (in bytes)
   isOS_S16 num_blocks;     //-- Capacity (Fixed-sized blocks actual max qty)
   isOS_S16 fblkcnt;        //-- Num of free blocks
   isOS_S32 id_fmp;         //-- ID for verification(is it a fixed-sized blocks memory pool or another object?)
                            // All Fixed-sized blocks memory pool have the same id_fmp magic number (ver 2.x)
}isOS_MEM;





isOS_S32 isOS_MemCreate(isOS_MEM * fmp,
						void * start_addr,
						isOS_S16 num_blocks,
						isOS_U16 block_size
					);
isOS_S32 isOS_MemDelete(isOS_MEM * fmp);
isOS_S32 isOS_MemMalloc(isOS_MEM * fmp,void ** p_data,isOS_U32 timeout);
isOS_S32 isOS_MemFree(isOS_MEM * fmp,void * p_data);

#ifdef __cplusplus
}
#endif

#endif /* #if (OS_MEM_EN ==1 ) End*/
#endif /* __OS_MEM_H__ End */


